<template>
  <el-container>
    <el-header class="el-header"><el-button type="text" @click="goBack">&lt-首页</el-button> | {{ action }}</el-header>
    <el-main>
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="学生注册/编辑" name="first" class="table">
        <Stu_re_Form/>
      </el-tab-pane>
      <el-tab-pane label="教师注册/编辑" name="second" class="table">
        <Ter_re_Form/>
      </el-tab-pane>
    </el-tabs>
    </el-main>
  </el-container>
</template>

<script>
import Stu_re_Form from "@/components/Stu_re_Form";
import Ter_re_Form from "@/components/Ter_re_Form";
export default {
  name: "Register",
  components: {
    Ter_re_Form,
    Stu_re_Form

  },
  created() {
    // 获取当前是否是“编辑”状态，是的话就自动降session中的信息填充上表单
    this.edit = sessionStorage.getItem("3")
    if (this.edit === "edit") {
      // 改边页头显示的内容
      this.action = "编辑"
      if (sessionStorage.getItem("2") === "教师") {
        this.activeName = 'second'
      }
    }
  },
  data() {
    return {
      activeName: 'first',
      action : "注册"
    }
  },
  methods : {
    // 跳回首页
    goBack(){
      this.$router.push({path:"/main"})
    },
  }
}
</script>

<style scoped>
  .table {
    margin: 0 auto;
  }
  .el-header {
    height: 40px;
    line-height: 40px;
    font-size: 30px;
  }
</style>